﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Configuration;
using log4net;

namespace LocalizationEditor
{
    public partial class FirstMessageForm : Form
    {
        private ILog log = LogManager.GetLogger(typeof(FirstMessageForm));

        public FirstMessageForm()
        {
            InitializeComponent();
        }

        private void buttonOK_Click(object sender, EventArgs e)
        {
            if (checkBoxNoShow.Checked)
            {
                try
                {
                    // Get the application configuration file.
                    Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);

                    AppSettingsSection section = config.AppSettings;

                    if (section != null)
                    {
                        section.Settings["showFirstUseMessage"].Value = false.ToString();
                        config.Save();
                    }
                }
                catch (Exception x)
                {
                    string message = "Unable to save to configuration file.";
                    log.Error(message, x);
                    MessageBox.Show(this, message);
                } 
            }

            Close();
        }
    }
}
